let jk = require('./jiankang')
// node环境中这种引入方法不执行
// import * as jk from './jiankang.js'

// 1.对应第一个函数的用法，判断数据的类型
let obj1 = {
  name: '顿健康',
  age: 18
}

let arr1 = [1, 3, 5]

// console.log(jk.isTypeOf(obj1))
// console.log(jk.isTypeOf(arr1))

// 2. 对应第二个函数 对象转数组
let obj2 = { 0: 'a', 1: 'b', 2: 'c' }
let res2 = jk.changeTypeToArray(obj2, 'key', 'value')
// console.log(res2)

// 3.对应第三个函数 数组转对象
let arr3 = [
  { id: 1, value: '正式' },
  { id: 2, value: '非正式' }
]
let res3 = jk.changeTypeToObject(arr3)
// console.log(res3)

// 4.对应第四个函数，除去对象中的空值
let obj4 = {
  name: '顿健康',
  age: 18,
  gender: ''
}
let res4 = jk.cleanObjectNullValue(obj4)
// console.log(res4);

// 5.对应第五个函数，处理树形结构
let arr5 = [
  {
    id: 1,
    name: '11111111楼',
    pid: 0
  },
  {
    id: 2,
    name: '2楼',
    pid: 0
  },
  {
    id: 4,
    name: '1楼儿子2',
    pid: 1
  },
  {
    id: 6,
    name: '你是谁啊',
    pid: 4
  },
  {
    id: 12,
    name: '566666',
    pid: 2
  },
  {
    id: 13,
    name: '33333楼',
    pid: 0
  },
  {
    id: 14,
    name: '7567566765',
    pid: 13
  },
  {
    id: 15,
    name: '1312',
    pid: 6
  }
]
let res5 = jk.setTree2(arr5)
// console.log(res5)

// 6.对应第六个函数，递归取出最底层的数据
// 参考文献：https://www.cnblogs.com/zhujieblog/p/12816864.html
let arr6 = [
  {
    name: '所有物品',
    children: [
      {
        name: '水果',
        children: [
          { name: '苹果', children: [{ name: '青苹果' }, { name: '红苹果' }] }
        ]
      },
      {
        name: '主食',
        children: [
          {
            name: '米饭',
            children: [{ name: '北方米饭' }, { name: '南方米饭' }]
          }
        ]
      },
      {
        name: '生活用品',
        children: [
          {
            name: '电脑类',
            children: [{ name: '联想电脑' }, { name: '苹果电脑' }]
          },
          { name: '工具类', children: [{ name: '锄头' }, { name: '锤子' }] },
          {
            name: '生活用品',
            children: [{ name: '洗发水' }, { name: '沐浴露' }]
          }
        ]
      }
    ]
  }
]
let res6 = jk.diguifunction(arr6)
// console.log(res6)

// 对应第6.2个递归
let test = require('./ChinaArea')
// console.log(jk.digui(test));

// 8.对应第八个，截取字符串
let str8 = ['20210215', '20210216']
let res8 = jk.jiequAdd(str8, '-')
// console.log(res8)

// 9.对应第九个函数
let str9 = 'ceshi'
let res9 = jk.reverse(str9)
// console.log(res9)

// 10.对应第十个函数
let arr10 = [
  {
    name: 'jack',
    age: 10
  },
  {
    name: 'jack',
    age: 18
  },
  {
    name: 'tom',
    age: 18
  }
]
let res10 = jk.quchong(arr10, 'name')
// console.log(res10);

// 11.对应第十一个函数
let arr11 = [1, 1, 3, 5, 7, 1, 5, 3, 7, 5]
let res11 = jk.jiandanquchong(arr11)
// console.log(res11);

// 12.对应第十二个函数
let arr12 = [
  {
    name: 'jack',
    age: 10
  },
  {
    name: 'jack2',
    age: 18
  },
  {
    name: 'tom',
    age: 18
  }
]
let arr122 = [
  {
    name: 'jack',
    age: 10
  },
  {
    name: 'jack3',
    age: 18
  },
  {
    name: 'tom2',
    age: 18
  }
]
let res12 = jk.shuzuClean(arr12, arr122, 'name')
// console.log(res12)

// 对应第十三个函数
let arr13 = [1, 3, 5]
let arr132 = [2, 3, 6]
let res13 = jk.isRepeat(arr13, arr132)
// console.log(res13)

// 对应第十七个函数
let obj171 = {
  name: 'jack',
  age: 18
}
let obj172 = {
  name: 'jack',
  age: 18
}
let res17 = jk.ifCompare(obj171, obj172)
// console.log(res17)

// 对应第二十个函数
var arr20 = [1, 3, 5, 7, 9, 13, 56, 64]
// console.log(jk.getSum(arr20));
// 对应第二十一个函数
// console.log(jk.CompareDate(arr20,65));

// 对应第二十二个函数
// console.log(jk.ChangeColorStep('#013548', '#554851', 10))

// 对应第二十四个函数
const map = new Map()
map.set('key', 'value')
map.set('ConardLi', 'coder')

const set = new Set()
set.add('ConardLi')
set.add('coder')

const target = {
  field1: 1,
  field2: undefined,
  field3: {
    child: 'child'
  },
  field4: [2, 4, 8],
  empty: null,
  map,
  set,
  bool: new Boolean(true),
  num: new Number(2),
  str: new String(2),
  symbol: Object(Symbol(1)),
  date: new Date(),
  reg: /\d+/,
  error: new Error(),
  func1: () => {
    let t = 0
    // console.log('coder', t++)
  },
  func2: function (a, b) {
    return a + b
  }
}

const test1 = jk.deepClone(target)
target.field4.push(9)
// console.log('test1: ', test1);

// 对应第二十五个函数
const arr25 = ['1', '3', '5']
// console.log(arr25);
let brr25 = jk.toNumber(arr25)
// console.log(brr25);

// console.log('测试函数', jk.checkValueExistence('  '))

// 对应第三十一个
// let arr31 = [1, 3, 5, 7]
// let list31 = jk.remove2(arr31, 7)
// console.log(list31)

// 对应34
let arr34 = [
  {
    name: 'tom1',
    age: 10
  },
  {
    name: 'tom2',
    age: 10
  },
  {
    name: 'tom3',
    age: 10
  },
  {
    name: 'tom4',
    age: 10
  },
  {
    name: 'tom5',
    age: 10
  }
]

let brr34 = ['tom1', 'tom3']

jk.deleteSth(arr34, brr34)
console.log(arr34);
